home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Games of Daze
/
Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso
/
x2ftp
/
msdos
/
vla
/
viewtga
/
clsub.asm
< prev
next >
Wrap
Assembly Source File
|
1994-01-10
|
2KB
|
97 lines
IDEAL
MODEL SMALL
STACK 200h
p386n
──────────────────────────────────────────────────────────────────────
CODESEG
──────────────────────────────────────────────────────────────────────
PUBLIC GetCommandLine
InputLength dw 0
FileNameOff dw 0 ;offset from CS: to filename
──────────────────────────────────────────────────────────────────────
┌────────────────────────────────────────────────
; File: CLSUB.ASM
;
; ┌────────────────────────────────────────────────
; Proc: GetCommandLine
;
; Entry:
;
; ES = PSP SEG
; CS:DX = pointer to filename area
; CS:BX = pointer to 5 byte 0 terminating Extension to add
;
; Return:
;
; AX = length of command line
; └────────────────────────────────────────────────
;
└────────────────────────────────────────────────
PROC GetCommandLine
pusha
push es ;push the PSP seg
pop ds ;pop it into DS
push bx ;save offset to Extension
mov [cs:FileNameOff],DX
mov [cs:InputLength],0 ;reset length read
mov si,128
lodsb
xor cx,cx
mov cl,al
or cx,cx
je @@CapDone
mov ax,cs
mov es,ax
mov di,[cs:FileNameOff]
xor bl,bl
@@NoSpace:
or cx,cx
je @@DoneName
dec cx
lodsb
or al,al
je @@DoneName
cmp al,' '
jbe @@NoSpace
stosb
inc bl
cmp bl,8
jb @@NoSpace
@@DoneName:
xor bh,bh
mov [cs:InputLength],bx
mov ax,cs
mov ds,ax
pop si
push si
mov cx,5 ;copies extension to end of filename
rep movsb
@@Capdone:
pop si
popa
mov ax,[cs:InputLength] ;return # of bytes
ret
ENDP GetCommandLine
END